﻿package org.leles.engines.beatgame 
{
	import org.leles.common.ITaggedObject;
	
	/**
	 * ...
	 * @author Bruno leles
	 */
	public class BeatGameTrack extends BeatGameObject
	{
		protected var _track:uint;
		protected var _notes:Array/*of BeatGameNote*/;
		protected var _holding:Boolean;
		
		public function BeatGameTrack(track:uint) 
		{
			super();
			_track = track;
			_notes = new Array();
			_holding = false;
		}
		
		public function addNote(note:BeatGameNote):void 
		{
			_notes.push( note );
		}
		
		public function removeNote(note:BeatGameNote):void 
		{
			var i:Number = 0, n:Number = _notes.length;
			while ( i < n )
			{
				if ( note === _notes[i] )
				{
					_notes.splice(i, 1);
				}
				i++;
			}
		}
		
		public function removeAllNotes():void 
		{
			while (_notes.length) 
			{
				removeNote( _notes[0] as BeatGameNote);
			}
		}
		
		public function getNote(index:Number):BeatGameNote 
		{
			return _notes[index] as BeatGameNote;
		}
		
		public function get holding():Boolean { return _holding; }
		
		public function set holding(value:Boolean):void 
		{
			if ( value == _holding ) return;
			_holding = value;
		}
		
		public function get track():uint { return _track; }
		
		public function get notes():Array { return _notes; }
		
		
	}
	
}